﻿// ****************************************************************************** //
//        Module for definition of river objects and their initial state          //
// ****************************************************************************** //

module RiverTypes

open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Input
open Microsoft.Xna.Framework.Graphics
open Utilities
open Casanova
open Coroutines
open Math


type RiverState = 
  {
   Trunks1              : Variable<List<Trunk>>
   Trunks2              : Variable<List<Trunk>>
   Leaf1                : Variable<List<Leaf>>
   Leaf2                : Variable<List<Leaf>>
  }

and Trunk =
  {
    PositionX         : Variable<float32>
    PositionY         : Variable<float32>
    PositionZ         : Variable<float32>
    mutable box       : BoundingBox
    VelX              : float32
  }

and Leaf =
  {
    PositionX         : Variable<float32>
    PositionY         : Variable<float32>
    PositionZ         : Variable<float32>
    mutable box       : BoundingBox
    VelX              : float32
  }
  

let mutable river_state =  //initial state
  {
    Trunks1 = Variable(fun () -> [])
    Trunks2 = Variable(fun () -> [])
    Leaf1 = Variable(fun () -> [])
    Leaf2 = Variable(fun () -> [])
  }


let reset_state () =
    river_state <-
        {
            Trunks1 = Variable(fun () -> [])
            Trunks2 = Variable(fun () -> [])
            Leaf1 = Variable(fun () -> [])
            Leaf2 = Variable(fun () -> [])
        }